package com.jianshuai.controller;

import com.jianshuai.service.IBuildService;
import com.jianshuai.domain.Floor;
import com.jianshuai.service.IFloorService;
import com.jianshuai.dto.House;
import com.jianshuai.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/build")
public class FloorController {

    @Autowired
    private IFloorService iFloorService;

    @Autowired
    private IBuildService iBuildService;



    @PostMapping("/addFloor")
    public JSONResult addFloor(@RequestBody List<Floor> floors){
        for (Floor f : floors){
            System.out.println("对象为：========:"+f);
        }
        return iFloorService.addFloor(floors);
    }

    @GetMapping("/getDeviceListByBuildId")
    public JSONResult<House> getDeviceListByBuildId(@RequestParam("id") int id){
        System.out.println("id为:===========******:"+id);
        return iBuildService.getDeviceListByBuildId(id);
    }

    @GetMapping("/getDeviceListByDeviceType")
    public JSONResult getDeviceListByDeviceType(@RequestParam("type") Long type){
        return iBuildService.getDeviceListByDeviceType(type);
    }

}
